<html>
<head><meta charset="utf-8"><title>PSA: `cargo xtask codegen` is no more · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PSA.3A.20.60cargo.20xtask.20codegen.60.20is.20no.20more.html">PSA: `cargo xtask codegen` is no more</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="229353544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PSA%3A%20%60cargo%20xtask%20codegen%60%20is%20no%20more/near/229353544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PSA.3A.20.60cargo.20xtask.20codegen.60.20is.20no.20more.html#229353544">(Mar 08 2021 at 18:52)</a>:</h4>
<p><code>cargo test</code> now not only complains that the generated files are out of date, but actually updates them.</p>



<a name="229354932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PSA%3A%20%60cargo%20xtask%20codegen%60%20is%20no%20more/near/229354932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jeremy Kolb <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PSA.3A.20.60cargo.20xtask.20codegen.60.20is.20no.20more.html#229354932">(Mar 08 2021 at 19:00)</a>:</h4>
<p>with an argument or automagically?</p>



<a name="229355837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PSA%3A%20%60cargo%20xtask%20codegen%60%20is%20no%20more/near/229355837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PSA.3A.20.60cargo.20xtask.20codegen.60.20is.20no.20more.html#229355837">(Mar 08 2021 at 19:05)</a>:</h4>
<p>automaticaly</p>



<a name="229357708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PSA%3A%20%60cargo%20xtask%20codegen%60%20is%20no%20more/near/229357708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PSA.3A.20.60cargo.20xtask.20codegen.60.20is.20no.20more.html#229357708">(Mar 08 2021 at 19:16)</a>:</h4>
<p>In other news: I <del>accidentally</del> deleted code model: <a href="https://github.com/rust-analyzer/rust-analyzer/pull/7923/files#diff-944d99df715f999866d3a80e35878b60657395e2472b1715edd6dbbb43aa0663">https://github.com/rust-analyzer/rust-analyzer/pull/7923/files#diff-944d99df715f999866d3a80e35878b60657395e2472b1715edd6dbbb43aa0663</a></p>



<a name="229905189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PSA%3A%20%60cargo%20xtask%20codegen%60%20is%20no%20more/near/229905189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chetan Khilosiya <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PSA.3A.20.60cargo.20xtask.20codegen.60.20is.20no.20more.html#229905189">(Mar 11 2021 at 18:53)</a>:</h4>
<p>for doctest in assists, the cargo test updates <a href="http://generated.rs">generated.rs</a> file only if the test is not present.<br>
If the generated test is present and we modify the doc then it will not update that test.<br>
cargo xtask codegen used to do that.</p>



<a name="230008831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PSA%3A%20%60cargo%20xtask%20codegen%60%20is%20no%20more/near/230008831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PSA.3A.20.60cargo.20xtask.20codegen.60.20is.20no.20more.html#230008831">(Mar 12 2021 at 10:48)</a>:</h4>
<p>Hm, this seem to work for me?</p>
<div class="codehilite"><pre><span></span><code>13:47:42|~/projects/rust-analyzer|master✓
λ git diff
diff --git a/crates/ide_assists/src/handlers/flip_comma.rs b/crates/ide_assists/src/handlers/flip_comma.rs
index 7f5e75d34..c19c992d1 100644
--- a/crates/ide_assists/src/handlers/flip_comma.rs
+++ b/crates/ide_assists/src/handlers/flip_comma.rs
@@ -8,13 +8,13 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
 //
 // ```
 // fn main() {
-//     ((1, 2),$0 (3, 4));
+//     ((1, 2),$0 (3, 92));
 // }
 // ```
 // -&gt;
 // ```
 // fn main() {
-//     ((3, 4), (1, 2));
+//     ((3, 92), (1, 2));
 // }
 // ```
 pub(crate) fn flip_comma(acc: &amp;mut Assists, ctx: &amp;AssistContext) -&gt; Option&lt;()&gt; {

13:47:55|~/projects/rust-analyzer|master⚡*
λ cargo t -p xtask
    Finished test [unoptimized] target(s) in 0.02s
     Running target/debug/deps/xtask-6e8e853982ebb953

running 11 tests
test tidy::generate_lint_completions ... ignored
test tidy::check_code_formatting ... ok
test tidy::check_merge_commits ... ok
test tidy::check_lsp_extensions_docs ... ok
test tidy::generate_parser_tests ... ok
test tidy::check_licenses ... ok
test tidy::cargo_files_are_tidy ... ok
test tidy::generate_assists_tests ... FAILED
test tidy::generate_grammar ... ok
test tidy::rust_files_are_tidy ... ok
test tidy::smoke_test_generate_documentation ... ok

failures:

---- tidy::generate_assists_tests stdout ----

error: crates/ide_assists/src/tests/generated.rs was not up-to-date, updating

thread &#39;tidy::generate_assists_tests&#39; panicked at &#39;called `Result::unwrap()` on an `Err` value: some file were not up to date&#39;, xtask/src/tidy.rs:22:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    tidy::generate_assists_tests

test result: FAILED. 9 passed; 1 failed; 1 ignored; 0 measured; 0 filtered out; finished in 1.70s

error: test failed, to rerun pass &#39;-p xtask --bin xtask&#39;

13:47:59|~/projects/rust-analyzer|master⚡*
λ git diff
diff --git a/crates/ide_assists/src/handlers/flip_comma.rs b/crates/ide_assists/src/handlers/flip_comma.rs
index 7f5e75d34..c19c992d1 100644
--- a/crates/ide_assists/src/handlers/flip_comma.rs
+++ b/crates/ide_assists/src/handlers/flip_comma.rs
@@ -8,13 +8,13 @@ use crate::{AssistContext, AssistId, AssistKind, Assists};
 //
 // ```
 // fn main() {
-//     ((1, 2),$0 (3, 4));
+//     ((1, 2),$0 (3, 92));
 // }
 // ```
 // -&gt;
 // ```
 // fn main() {
-//     ((3, 4), (1, 2));
+//     ((3, 92), (1, 2));
 // }
 // ```
 pub(crate) fn flip_comma(acc: &amp;mut Assists, ctx: &amp;AssistContext) -&gt; Option&lt;()&gt; {
diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs
index 304b5798f..b7bc139c0 100644
--- a/crates/ide_assists/src/tests/generated.rs
+++ b/crates/ide_assists/src/tests/generated.rs
@@ -388,12 +388,12 @@ fn doctest_flip_comma() {
         &quot;flip_comma&quot;,
         r#####&quot;
 fn main() {
-    ((1, 2),$0 (3, 4));
+    ((1, 2),$0 (3, 92));
 }
 &quot;#####,
         r#####&quot;
 fn main() {
-    ((3, 4), (1, 2));
+    ((3, 92), (1, 2));
 }
 &quot;#####,
     )
</code></pre></div>



<a name="230029811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PSA%3A%20%60cargo%20xtask%20codegen%60%20is%20no%20more/near/230029811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chetan Khilosiya <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PSA.3A.20.60cargo.20xtask.20codegen.60.20is.20no.20more.html#230029811">(Mar 12 2021 at 13:42)</a>:</h4>
<p>If I updated the doctest then the cargo test is failing. below is the output<br>
failures:</p>
<p>---- tidy::generate_assists_tests stdout ----</p>
<p>error: crates/ide_assists/src/tests/generated.rs was not up-to-date, updating</p>
<p>thread 'tidy::generate_assists_tests' panicked at 'called <code>Result::unwrap()</code> on an <code>Err</code> value: some file were not up to date', xtask/src/tidy.rs:22:39<br>
note: run with <code>RUST_BACKTRACE=1</code> environment variable to display a backtrace</p>
<p>failures:<br>
    tidy::generate_assists_tests</p>
<p>diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs<br>
index 5cfc4110f..54d43fd26 100644<br>
--- a/crates/ide_assists/src/tests/generated.rs<br>
+++ b/crates/ide_assists/src/tests/generated.rs<br>
@@ -700,6 +700,7 @@ impl MyStruct {<br>
     p$0ub fn len(&amp;self) -&gt; usize {<br>
         self.data.len()<br>
     }<br>
+<br>
 }<br>
 "#####,<br>
         r#####"<br>
@@ -711,6 +712,7 @@ impl MyStruct {<br>
     pub fn is_empty(&amp;self) -&gt; bool {<br>
         self.len() == 0<br>
     }<br>
+<br>
 }<br>
 "#####,<br>
     )</p>
<p>I am not sure its problem or issue in my doctest.</p>



<a name="230029921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PSA%3A%20%60cargo%20xtask%20codegen%60%20is%20no%20more/near/230029921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PSA.3A.20.60cargo.20xtask.20codegen.60.20is.20no.20more.html#230029921">(Mar 12 2021 at 13:43)</a>:</h4>
<p>I think it is supposed to fail but it will still update the files</p>



<a name="230030573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PSA%3A%20%60cargo%20xtask%20codegen%60%20is%20no%20more/near/230030573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chetan Khilosiya <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PSA.3A.20.60cargo.20xtask.20codegen.60.20is.20no.20more.html#230030573">(Mar 12 2021 at 13:47)</a>:</h4>
<p>yes it updates the generated file. I thought it will pass after updating file.</p>



<a name="230031582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/PSA%3A%20%60cargo%20xtask%20codegen%60%20is%20no%20more/near/230031582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Chetan Khilosiya <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/PSA.3A.20.60cargo.20xtask.20codegen.60.20is.20no.20more.html#230031582">(Mar 12 2021 at 13:54)</a>:</h4>
<p>I think it's not an issue then. :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>